// =============================================
// Author:		Onur Eker
// Create date: <Create Date,,>
// Description:	<Description,,>
// =============================================

using Bosphorus.Migrator.Core.MigrationCommand;
using Bosphorus.Migrator.Implementation.MigrationCommand;

namespace Bosphorus.Migrator.Facade.DdlSignature.Base
{
    public class DdlSignature<TDdlSignature> : ICommandProvider 
        where TDdlSignature : DdlSignature<TDdlSignature>
    {
        protected readonly ICommand command;

        public DdlSignature(ICommand command)
        {
            this.command = command;
        }

        protected TDdlSignature AddCreateSubCommand<TModel>(TModel model)
        {
            CreateCommand<TModel> createCommand = new CreateCommand<TModel>(model);
            command.SubCommands.Add(createCommand);
            return (TDdlSignature)this;
        }

        protected TDdlSignature AddAlterSubCommand<TModel>(TModel model, TModel oldModel)
        {
            AlterCommand<TModel> createCommand = new AlterCommand<TModel>(model, oldModel);
            command.SubCommands.Add(createCommand);
            return (TDdlSignature)this;
        }

        protected TDdlSignature AddDropSubCommand<TModel>(TModel model)
        {
            DropCommand<TModel> createCommand = new DropCommand<TModel>(model);
            command.SubCommands.Add(createCommand);
            return (TDdlSignature)this;
        }

        public ICommand Command
        {
            get { return command; }
        }
    }
}